package cn.com.dcsgo.security;

import cn.com.dcsgo.vo.user.UserLoginVo;

/**
 * 使用 ThreadLocal 存储用户信息
 *
 * @author Dcsgo
 * @since 2025/4/24 15:01
 */

public class AuthContextHolder {
    private static final ThreadLocal<Long> userId = new ThreadLocal<>();
    /**
     * 仓库id
     */
    private static final ThreadLocal<Long> wareId = new ThreadLocal<>();
    private static final ThreadLocal<UserLoginVo> userLoginVo = new ThreadLocal<>();

    public static void setUserId(Long userId) {
        AuthContextHolder.userId.set(userId);
    }

    public static Long getUserId() {
        return userId.get();
    }

    public static void setWareId(Long wareId) {
        AuthContextHolder.wareId.set(wareId);
    }

    public static Long getWareId() {
        return wareId.get();
    }

    public static void setUserLoginVo(UserLoginVo userLoginVo) {
        AuthContextHolder.userLoginVo.set(userLoginVo);
    }

    public static UserLoginVo getUserLoginVo() {
        return userLoginVo.get();
    }
}
